<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let num = '18579035107'
    let res = /^(\d{3})\d{4}(\d{4})$/ //带括号的 可以用 $1 $2..代替 没带括号的可以 用其他字符串替代 例如下面 用 ****替代 

    console.log(num.replace(res,'$1****$2'))
    
  </script>
</body>
</html>